/**
 * 收款登记查询管理初始化
 */
var CollectBasicInformation = {
    id: "CollectBasicInformationTable",	//表格id
    seItem: null,		//选中的条目
    table: null,
    layerIndex: -1
};

/**
 * 初始化表格的列
 */
CollectBasicInformation.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
        {title: '收款单号', field: 'collectId', visible: true, align: 'center', valign: 'middle'},
        {title: '审核状态', field: 'collectState', visible: true, align: 'center', valign: 'middle'},
        {title: '收款日期', field: 'collectDate', visible: true, align: 'center', valign: 'middle'},
        {title: '制单员', field: 'collectTradePerson', visible: true, align: 'center', valign: 'middle'},
        {title: '审核员', field: 'collectCheck', visible: true, align: 'center', valign: 'middle'},
        {title: '车号', field: 'collectCarId', visible: true, align: 'center', valign: 'middle'},
        {title: '驾驶员', field: 'collectCarDriver', visible: true, align: 'center', valign: 'middle'},
        {title: '电话', field: 'collectCarDriverTell', visible: true, align: 'center', valign: 'middle'},
        {title: '手机', field: 'collectCarDriverMobile', visible: true, align: 'center', valign: 'middle'},
        {title: '车次', field: 'collectCarNumber', visible: true, align: 'center', valign: 'middle'},
        {title: '物流线路', field: 'collectRouteId', visible: true, align: 'center', valign: 'middle'},
        {title: '始发站', field: 'collectRouteStart', visible: true, align: 'center', valign: 'middle'},
        {title: '终点站', field: 'collectRouteEnd', visible: true, align: 'center', valign: 'middle'},
        {title: '运费', field: 'collectSumGoodsFreight', visible: true, align: 'center', valign: 'middle'},
        {title: '信息费', field: 'collectSumGoodsMessagefee', visible: true, align: 'center', valign: 'middle'},
        {title: '提货费', field: 'collectSumGoodsPickupCharge', visible: true, align: 'center', valign: 'middle'},
        {title: '中转站', field: 'collectRouteTransferStation', visible: true, align: 'center', valign: 'middle'},
        {title: '总费用', field: 'collectSumFee', visible: true, align: 'center', valign: 'middle'},
        {title: '本次收款', field: 'collectThisMoney', visible: true, align: 'center', valign: 'middle'},
        {title: '收费余额', field: 'collectUncollectMoney', visible: true, align: 'center', valign: 'middle'},
        {title: '收款方式', field: 'collectType', visible: true, align: 'center', valign: 'middle'},
        {title: '备注', field: 'collectRemark', visible: true, align: 'center', valign: 'middle'}
    ];
};

/**
 * 检查是否选中
 */
CollectBasicInformation.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录！");
        return false;
    }else{
        CollectBasicInformation.seItem = selected[0];
        return true;
    }
};



/**
 * 打开查看收款登记查询详情
 */
CollectBasicInformation.openCollectBasicInformationDetail = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: '收款登记查询详情',
            area: ['800px', '500px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/collectBasicInformation/collectBasicInformation_updatequery/' + CollectBasicInformation.seItem.id
        });
        this.layerIndex = index;
        layer.full(index);
    }
};



/**
 * 查询表单提交参数对象
 * @returns {{}}
 */
CollectBasicInformation.formParams = function() {
    var queryData = {};
    queryData['collectId'] = $("#collectId").val();
    queryData['collectDate'] = $("#collectDate").val();
    queryData['collectTradePerson'] = $("#collectTradePerson").val();
    queryData['collectCarId'] = $("#collectCarId").val();
    queryData['collectCarNumber'] = $("#collectCarNumber").val();
    queryData['collectCarDriver'] = $("#collectCarDriver").val();
    queryData['collectRouteId'] = $("#collectRouteId").val();
    queryData['collectRouteStart'] = $("#collectRouteStart").val();
    queryData['collectRouteEnd'] = $("#collectRouteEnd").val();
    return queryData;
}

/**
 * 查询收款登记查询列表
 */
CollectBasicInformation.search = function () {
	CollectBasicInformation.table.refresh({query: CollectBasicInformation.formParams()});
};

$(function () {
    var defaultColunms = CollectBasicInformation.initColumn();
    var table = new BSTable(CollectBasicInformation.id, "/collectBasicInformation/listbossquery", defaultColunms);
    table.setPaginationType("server");
    table.setQueryParams(CollectBasicInformation.formParams());
    CollectBasicInformation.table = table.init();
});
